/**
 * Created by Administrator on 2017/7/24.
 */

   //保存视频播放位置
   function saveVideoPosition(param) {

    $.ajax({
        url: appPath + "/student/videoPosition/savePosition",
        data: param,
        type: "post",
        dataType:"json",
        success:function(data) {
            //console.log(data);
        },
        complete:function(){
            // studentStudy.messenger.targets['parent1'].send("我特么学完了");
        }
    });
   }

    //保存视频播放位置
    function saveAdminVideoPosition(param) {
        $.ajax({
            url: appPath + "/popup/savePosition",
            data: param,
            type: "post",
            dataType:"json",
            success:function(data) {
                //console.log(data);
            },
            complete:function(){
                // studentStudy.messenger.targets['parent1'].send("我特么学完了");
            }
        });
    }



   function getVideoPosition(param) {
       var last_position = 0;
       $.ajax({
           url: appPath + "/student/videoPosition/getPosition",
           data: param,
           type: "post",
           dataType:"json",
           success:function(data) {

               //console.log(data);

                   last_position = data;


           },
           complete:function(){
               // studentStudy.messenger.targets['parent1'].send("我特么学完了");
           }
       });
       return last_position;
   }

    function getAdminVideoPosition(param) {
        var last_position = 0;
        $.ajax({
            url: appPath + "/popup/getPosition",
            data: param,
            type: "post",
            dataType:"json",
            success:function(data) {

                //console.log(data);

                last_position = data;


            },
            complete:function(){
                // studentStudy.messenger.targets['parent1'].send("我特么学完了");
            }
        });
        return last_position;
    }


var count = 0;
var outTime = 1200;// 分钟
var docListener1 = null;
function docListener() {
    if(docListener1 != null){
        window.clearInterval(docListener1);
    }
    console.log(count)
    count++;
    if(count == outTime){
        if(doc_time1 != null){
            window.clearInterval(doc_time1);
        }
        console.log(doc_time1)
        window.clearInterval(docListener1);
        var index = layer.alert('您已学习此文档20分钟了，请确定是否继续学习 :-D',{title:'温馨提示:',closeBtn: 0},function(){
            doc_time();
            count = 0;
            layer.close( index );
        })
    }
    docListener1 =  window.setInterval("docListener()",1000);
}

// 监听鼠标
window.onmousemove = function (event) {
    count = 0;
};


// 监听键盘
document.onkeydown = function () {
    count = 0;
};







